﻿using B.S.BasicData.ErrorCode;
using B.S.BasicData.Read.Apilication.Common.Exec;
using B.S.BasicData.Read.Apilication.Common.Leave;
using B.S.BasicData.Read.DTOS;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Read.Controllers
{
    /// <summary>
    /// Api 控制器-读(请假审批)
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class LeaveController : ControllerBase
    {
        private readonly IMediator mediator;

        public LeaveController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 审批列表显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaimg<LeaveDto>> leaveShow([FromQuery]GetLeaveCommand command)
        { 
            return mediator.Send(command);
        }

        /// <summary>
        /// 查询部门领导
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<string>> DepartShow([FromQuery]GetDepartmentCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 报表信息查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<ReportDto>>> GetleaveHandles([FromQuery] GetleavesummaryCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 报表信息详情
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<LeavePortDto>>> GetleaveDetailHandle([FromQuery] GetleaveDetailCommon request)
        {
            return await mediator.Send(request);
        }


    }
}
